package com.dkd.service.impl;


import cn.elegent.token.dto.ElegentUser;
import cn.elegent.token.refresh.service.UserService;
import com.dkd.config.constant.LoginType;
import com.dkd.dto.UserDTO;
import com.dkd.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * UserDetailServiceImpl
 *
 * @author: wgl
 * @describe: TODO
 * @date: 2022/12/28 10:10
 */
@Service
public class UserDetailServiceImpl implements UserService {

    @Autowired
    private com.dkd.service.UserService dkdUserService;

    @Override
    public ElegentUser getUserDetail(String id, Map params) {
        UserEntity userEntity = dkdUserService.getById(Integer.valueOf(id));
        UserDTO userDTO=new UserDTO();
        userDTO.setUserId(userEntity.getId()+"");
        userDTO.setMobile(userEntity.getMobile());
        List<String> roles=new ArrayList<>();
        //帝可得目前一个端一个角色
        LoginType loginType = LoginType.getByCode(Integer.valueOf(params.get("loginType").toString()));
        roles.add(loginType.getName());
        userDTO.setRoles(roles);
        return userDTO;
    }
}
